#ifndef MY_SERVER_H
#define MY_SERVER_H

#include <netinet/in.h>
#include "mainconfig.h"

typedef struct sock_queuen_node
{
	struct sockaddr  accept_addr;
	int accepted_sock_fd;
}SockQueueNode; 

typedef struct  my_server
{
	struct sockaddr_in	server_addr;
	int sq_head;
	int sq_tail;
	struct sock_queuen_node sock_queue[SOCK_QUEUE_LEN];
	
	pthread_mutex_t sq_mutex;
	pthread_cond_t   sq_cond;

	int serversock_fd;
	int stop_flag;

	pthread_mutex_t  workercnt_mutex;
	int num_workerThread;
}my_server;


my_server * init_myserver();
int start_myserver(my_server * pserver);
int monitor_Thread(my_server * pserver);
int worker_thread(my_server  * pserver);
int add_new_connection(my_server *pserver);
int store_new_connect_queue(int sock_fd,my_server * pserver,struct sockaddr * aceptsock);
int close_myserver(my_server * pserver);
int getValidsock(my_server * pserver ,struct sock_queuen_node * psq );
int close_myserver(my_server * pserver);






#endif
